@extends('layouts.master')
@section('content') 
<link href="{{ asset('assets/css/daterangepicker.css')}}" rel="stylesheet">
<script src="{{ asset('assets/js/moment.js')}}"></script>
<script src="{{ asset('assets/js/daterangepicker.js')}}"></script>
<div class="row">
	<div id="breadcrumb" class="col-md-12">
		<ol class="breadcrumb">
			<li><a href="{{Config::get('config.domain')}}dashboard">Dashboard</a></li>
			<li><a href="{{Config::get('config.domain')}}news">News Listings</a></li>
		</ol>
	</div>
</div>
<div class="row">
	<div class="col-xs-12">
		<div class="box">
			<div class="box-header">
				<div class="box-name">					
					<span>News Listings</span>
					<a href="{{Config::get('config.domain')}}news/add" style="float: right;padding-right:10px;"><button class="btn btn-primary" type="buttom">Add new</button></a>
				</div>
				
			</div>
			<div class="box-content no-padding">
				@if(Session::has('success'))
					    <div class="alert-box success">
					      <center> {{ Session::get('success') }}</center>
					    </div>
					@endif
					@if(Session::has('errMg'))
					    <div class="alert-box errMg">
					      <center> {{ Session::get('errMg') }}</center>
					    </div>
					@endif
				<table class="table table-bordered table-striped table-hover table-heading table-datatable" id="datatable-1">
					<thead>
						<tr>
							
							<th>News title</th>
							<th>Category</th>
							<th>Posted Date</th>
							<th>Status</th>
							<th>Top Story</th>
							<th>Action</th>
						</tr>
											
					</thead>
					<tbody>
					<!-- Start: list_row -->
						<tr>
							<form class="form-horizontal" method="get" >
							
							<td>
								<input type="text"  name="name" class="form-control" value="<?php if($name) echo $name ;?>"  style="width:220px;display:initial">
							</td>
							<td>
								<select style="width:150px;display:initial" id="category" name="category" class=" form-control">
									<option>All</option>
									@foreach($listCategory as $key=>$cat)
										<option value="{{$key}}" @if(!empty($category)&& $category==$key) selected="true" @endif >{{$cat}}</option>									
									 @endforeach
									
								</select>
							</td>
							
							<td><input class="form-control" name="daterange" id="id-date-range-picker-1" style="width:180px;display:initial" value="<?php if($daterange) { echo $daterange; }?>" type="text"></td>
							
								<td>
								<select style="width:80px;display:initial" id="st" name="st" class=" form-control">
									<option>All</option>
									<option value="1"  <?php if(!empty($st) && $st==1){ echo 'selected="true"';}?> >Active</option>									
									<option value="'0'"  <?php if(!empty($st) && $st=="'0'"){ echo 'selected="true"'; }?> >Inactive</option>
									
								</select>
							</td>
							<td><center><a class="btn btn-primary" style="background: #5a5a5a;" href="">View All</a></center></td>
							<td><button class="btn btn-primary" type="submit">Search</button></td>
							</from>
						</tr>
						@foreach($dataAll as $data)
						<tr>							
							<td>
								<img class="img-rounded" src="{{$data->featurePhoto}}" alt="">
								{{$data->title}}
							</td>
							<td>{{$data->name}}</td>
							<td>{{ date("d-M-Y",strtotime($data->created_at)) }}</td>
							<td>
								
								
								<ul class="status-option panel-menu">							
									<li class="dropdown">
										<a href="#" class="dropdown-toggle account" data-toggle="dropdown">
											{{ $statusAll[$data->status] }}
											<span class="fa fa-angle-down"></span>											
										</a>
										<ul class="dropdown-menu">			
											@foreach($statusAll as $key=>$value)
											<li>
												<a href="{{Config::get('config.domain')}}news/changes/{{ $data->id .'-'.$value}}">
													<span>{{$value}}</span>
												</a>
											</li>
											@endforeach
										</ul>
									</li>
								</ul>
								
								
							
							</td>
							<td style="text-align:center"><i class="fa fa-flag"></i></td>
							<td style="text-align:center">
								<a href="{{Config::get('config.domain')}}news/edit/{{$data->id}}"><i class="fa fa-pencil-square-o"></i></a>
								<a href="javascript:confirmDelete('{{Config::get('config.domain')}}news/delete/{{$data->id}}')">
									<span class="fa fa-trash-o" style="float:none"></span>
								</a>
							</td>
						</tr>
						@endforeach
						
					<!-- End: list_row -->
					</tbody>
				
				</table>

			</div>
		</div>
	</div>

	<div class="box-content" style="text-align: center">
	<div class="dataTables_paginate paging_bootstrap">
				 {{ $dataAll->appends(Input::except('page'))->links(); }}
	</div>
	<div class="clearfix"></div>
	</div>
</div>
<script type="text/javascript">
	$('#id-date-range-picker-1').daterangepicker().prev().on(ace.click_event, function(){
	$(this).next().focus();
	});
	function confirmDelete(delUrl){
		if (confirm("Are you sure to delete this item ?"))	{
			document.location = delUrl;
		}
	}
</script>
@stop